package com.sport.annotation;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;

public class StoreAreaSerializer extends JsonSerializer<Integer> {

    @Override
    public void serialize(Integer storeArea, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        String retailerType = getRetailerType(storeArea);
        gen.writeString(retailerType);
    }

    private String getRetailerType(Integer storeArea) {
        if (storeArea != null) {
            if (storeArea <= 50) {
                return "小型零售商";
            } else if (storeArea <= 200) {
                return "中型零售商";
            } else {
                return "大型零售商";
            }
        } else {
            return "未知";
        }
    }
}

